package com.ternnetwork.core.accesscontroll.service.impl;

import com.ternnetwork.core.accesscontroll.service.UserService;
import com.ternnetwork.persistence.entity.VersionEntity;

import java.util.Date;

public class AuditInfoServiceImpl {

    private final UserService userService;

    public AuditInfoServiceImpl(UserService userService) {

        this.userService = userService;
    }


    protected void setCreateInfo(String userName, VersionEntity t) {
        long userId=userService.findByName(userName).getId();
        t.setCreatedById(userId);
        t.setCreateTime(new Date());
    }

    protected void setUpdateInfo(String userName, VersionEntity t) {
        long userId=userService.findByName(userName).getId();
        t.setUpdatedById(userId);
        t.setUpdateTime(new Date());
    }


}
